<template>
	<view class="location">
		<image src="../static/icons/location.png" class="location_img" @click="gotolocation"></image>
		<i>{{addressText}}</i>
	</view>
</template>

<script>
	export default{
		props:["latitude","longitude"],
		data(){
			return{
			addressText:'asdasd',
			}
		},
		watch:{
			latitude(newVal,oldVal){				
					let QQMapWX = require('utils/qqmap-wx-jssdk.js')
					let qqmapsdk = new QQMapWX({
					key: 'G7RBZ-QFQWD-YNL4F-POIO2-EJQI3-2RFRC'
				});
						
						 qqmapsdk.reverseGeocoder({
						       location: {
						         latitude: this.latitude,
						         longitude:this.longitude,
								 },
						       success: (res)=> {
						           console.log(res);
								   this.addressText=res.result.address
								   console.log(this.addressText)
						           },
						       fail:(res)=> {
						           console.log(res);
						           },
				
						    });
			}
		},
		methods:{
			gotolocation(){
				uni.setStorage({
					key:"latitude",
					data:this.latitude
					
				})
				uni.setStorage({
				
					key:"longitude",
					data:this.longitude
				})
				uni.navigateTo({
					url:"/components/showMap"
				})
			}
		}


	}
</script>

<style lang="less">
	.location{
		display: flex;
		.location_img{
			height:36rpx;
			width:36rpx;
		}
		i{
			display: inline-block;
			margin-left:10rpx;
			line-height: 35rpx;
			font-size: 15px;
			color: #ba59ff;
		}
	}
</style>
